﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PlatForm.DataLayer;

namespace PlatForm.Controller
{
    public class StoreController
    {
        public List<Store> GetList()
        {
            return Store.Objects.ToList();
        }

        public int Save(Store store)
        {
            var isNew = 1;
            var s = Store.Objects.FirstOrDefault(x => x.ST_No == store.ST_No);
            if (s != null)
            {
                Store.Objects.Delete(x => x.ST_No == store.ST_No);
                isNew = 0;
            }
            store.Insert(true);
            return isNew;
        }

        public void Delete(string ST_No)
        {
            Supplier.Objects.Delete(x => x.SUPPL_No == ST_No);
        }
    }
}
